import { maxLengthText, requiredText } from "../validator/message";

const baseInfoRule = {
  custNo: [{ required: true, message: requiredText, trigger: 'blur' }],
  custName: [{ required: true, message: requiredText, trigger: 'blur' }],
  customerType: [{ required: true, message: requiredText, trigger: 'change' }],
  voltageGrade: [{ required: true, message: requiredText, trigger: 'change' }],
  tradeCode: [{ required: true, message: requiredText, trigger: 'change' }],
  custStatus: [{ required: true, message: requiredText, trigger: 'change' }],
  address: [{ required: true, message: requiredText, trigger: 'blur' }],
  orgNo: [{ required: true, message: requiredText, trigger: 'change' }],
  name: [{ required: true, message: requiredText, trigger: 'blur' }],
  areaNo: [{ required: true, message: requiredText, trigger: 'change' }],
  //sex: [{ required: true, message: requiredText, trigger: 'change' }],
  //contactAddress: [{ required: true, message: requiredText, trigger: 'blur' }],

  //creditlevel: [{ required: true, message: requiredText, trigger: 'change' }]
}
const siteInfoRule = {
  siteNo: [{ required: true, message: requiredText, trigger: 'blur' }],
  // siteName: [{ required: true, message: requiredText, trigger: 'blur' }],
  siteType: [{ required: true, message: requiredText, trigger: 'change' }],
  areaNo: [{ required: true, message: requiredText, trigger: 'change' }],
  runStatus: [{ required: true, message: requiredText, trigger: 'change' }],
  posY: [{ required: true, message: requiredText, trigger: 'blur' }],
  posX: [{ required: true, message: requiredText, trigger: 'blur' }],
  runTime: [{ required: true, type: 'date', message: requiredText, trigger: 'change' }]
}

const eneryDataRule = {
  energyUnitType: [{ required: true, message: requiredText, trigger: 'change' }],
  orgNo: [{ required: true, message: requiredText, trigger: 'change' }],
  areaNo: [{ required: true, message: requiredText, trigger: 'change' }],
  focusUnits: [{ required: true, message: requiredText, trigger: 'blur' }],
  isVirtualUnit: [{ required: true, message: requiredText, trigger: 'blur' }],
}

const mearurPonitSelect = {

  instLoc: [{ required: true, message: requiredText, trigger: 'blur' }],
  statusCode: [{ required: true, message: requiredText, trigger: 'change' }],
  measDeviceCode: [{ required: true, message: requiredText, trigger: 'change' }],
  measPointNo: [{ required: true, message: requiredText, trigger: 'blur' }],
  commMode: [{ required: true, message: requiredText, trigger: 'change' }],
  protocolCode: [{ required: true, message: requiredText, trigger: 'change' }],
  commAddr: [
    { required: true, message: requiredText, trigger: 'change' },
    { max: 64, message: maxLengthText + '64', trigger: 'change' },
  ],
  baudrateCode: [{ required: true, message: requiredText, trigger: 'change' }],
  measName: [{ required: true, message: requiredText, trigger: 'blur' }]
  // stopBit: [{ required: true, type: 'number', message: requiredText, trigger: 'blur' }],
  // calibrationBit: [{ required: true, message: requiredText, trigger: 'change' }]
}

const colectPonitSet = {
  custName: [{ required: true, message: requiredText, trigger: 'change' }],
  assetNo: [{ required: true, message: requiredText, trigger: 'change' }],
  commName: [{ required: true, message: requiredText, trigger: 'blur' }],
  commNo: [{ required: true, message: requiredText, trigger: 'blur' }],
  commType: [{ required: true, message: requiredText, trigger: 'change' }],
  installDate: [{ required: true, type: 'string', message: requiredText, trigger: 'change' }],
  cpAddr: [{ required: true, message: requiredText, trigger: 'blur' }],
  cpTypeCode: [{ required: true, message: requiredText, trigger: 'change' }],
  statusCode: [{ required: true, message: requiredText, trigger: 'change' }],
  chnMain: [{ required: true, message: requiredText, trigger: 'change' }],
  ipAddr1: [{ required: true, message: requiredText, trigger: 'blur' }],
  conneUrl: [{ required: true, message: requiredText, trigger: 'change' }],
  commProtocol: [{ required: true, message: requiredText, trigger: 'change' }]
}

const creditlevelArr = [{
  'codeName': '最高信用度等级',
  'codeValue': '01'
}, {
  'codeName': '较高信用度等级',
  'codeValue': '02'
}, {
  'codeName': '高信用度等级',
  'codeValue': '03'
}, {
  'codeName': '中最高信用度等级',
  'codeValue': '04'
}, {
  'codeName': '中较高信用度等级',
  'codeValue': '05'
}, {
  'codeName': '中信用度等级',
  'codeValue': '06'
}, {
  'codeName': '一般最高信用度等级',
  'codeValue': '07'
}, {
  'codeName': '一般较高信用度等级',
  'codeValue': '08'
}, {
  'codeName': '一般信用度等级',
  'codeValue': '09'
}, {
  'codeName': '差信用度等级',
  'codeValue': '10'
}, {
  'codeName': '较差信用度等级',
  'codeValue': '11'
}, {
  'codeName': '最差信用度等级',
  'codeValue': '12'
}, {
  'codeName': '请输入评价得分',
  'codeValue': '13'
}]

// eslint-disable-next-line complexity
const scoreChangeFunction = num => {
  let val = null;
  const a = (num / (100 / 12 | 0)) | 0;
  const arr =['01','02']
  console.log(a);
  switch (true) {
    case num === 0:
      val = '13'
      break
    case num < 11 && num > 0:
      val = '12'
      break
    case num >= 11 && num < 21:
      val = '11'
      break
    case num >= 21 && num < 31:
      val = '10'
      break
    case num >= 31 && num < 41:
      val = '09'
      break
    case num >= 41 && num < 51:
      val = '08'
      break
    case num >= 51 && num < 61:
      val = '07'
      break
    case num >= 61 && num < 71:
      val = '06'
      break
    case num >= 71 && num < 81:
      val = '05'
      break
    case num >= 81 && num < 91:
      val = '04'
      break
    case num >= 91 && num < 101:
      val = '03'
      break
    case num >= 101 && num < 111:
      val = '02'
      break
    default:
      val = '01'
      break
  }
  return val
}

export {
  baseInfoRule,
  siteInfoRule,
  eneryDataRule,
  creditlevelArr,
  scoreChangeFunction,
  mearurPonitSelect,
  colectPonitSet
}
